<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>墨芽豆课堂</title>
    <link rel="stylesheet" href="css/api.css">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/playvideo.css">
    <style>
        .imgbox {
            position: relative;
            cursor: pointer;
        }

        .loginoutbox {
            position: absolute;
            right: -21px;
            top: 77px;
            width: 197px;
            line-height: 35px;
            background-color: #666;
            text-align: center
        }

        .play {
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            z-index: 999;
        }

        .play .playbox {
            position: absolute;
            width: 1200px;
            height: 600px;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            z-index: 999;
        }

        .play .playbox video {
            width: 100%;
            height: 100%;
        }

        .play .msk {
            position: fixed;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            z-index: 1;
            background-color: rgba(0, 0, 0, .6);
        }

        #pdf {
            position: absolute;
            width: 100%;
            left: 0;
            top: 0;
            height: 100%;
            display: none;
            z-index: 999;
        }

        #pdf .msk {
            position: absolute;
            /* width: 100%;
            height: 100%; */
            background-color: transparent;
            z-index: 999;
            right: 0;
            top: 0;
        }

        #buttons {
            display: none !important;
        }

        .guanbi {
            position: fixed;
            z-index: 9999;
            right: 46px;
            top: 30px;
            color: #fa4f62;
            border: 1px solid #fa4f62;
            border-radius: 5px;
            padding: 5px 15px;
            cursor: pointer;
            background-color: #fff;
        }

        #pdfbox {
            height: 100%;
            position: relative;
            z-index: 1;
        }

        .bgc {
            height: 50px;
            width: 100%;
            top: 0;
            left: 0;
            position: fixed;
            z-index: 998;
        }

        .playno {
            padding-top: 50%;
            position: relative;
            z-index: 999;
            text-align: center;
            transform: translateY(-50%);
        }
    </style>
</head>

<body>

    <div id="app" v-cloak>
        <div class="nav navbox">
            <div class="w1240 h">
                <div class="imgbox left">
                    <img src="../image/logo.png" alt="" class="logo"> PC课程端
                </div>
                <div class="tab">
                    <span :class="{active:selectIndex == index}" data-index="1" v-for="(item,index) in tabList"
                        @click="fnTabbar(index,item.status)">{{item.name}}</span>
                    <!-- <span data-index="2">考核管理</span>
                    <span data-index="3">上课历史</span>
                    <span data-index="4">老师考核</span> -->
                </div>
                <div class="imgbox" @click="loginBox">
                    <img :src="teacherInfo.avatar" alt="" class="logo touxiang" v-if="teacherInfo.avatar">
                    <img src="./image/b.png" alt="" v-if="!teacherInfo.avatar" class="logo touxiang">
                    {{teacherInfo.nickname}}
                    <div class="loginoutbox" v-if="loginoutboxFlag" @click="loginOut">
                        退出账号
                    </div>
                </div>
            </div>
        </div>
        <div class="content">
            <!-- <button @click="fnXueSubmit">点击</button> -->
            <!-- 上课 -->
            <div class="package">
                <template v-for="(item,index) in classList" v-if="tabFlag">
                    <div class="list">
                        <div class="time">
                            {{item.appoint_time}}
                        </div>
                        <div class="title">
                            {{item.class_name}}
                        </div>
                        <div class="order" ref="abc">
                            预约人 {{item.student_nickname}}
                            <div class="btn">
                                <span class="shangke" :data-starttime="item.appoint_time" :data-appintid="item.id"
                                    :data-index="index" @click="fnStartClass(item)"
                                    v-if="item.status_extra != 3">开始上课</span>
                                <!-- <span class="shangke" v-if="item.status == '已结束'" >已结束</span> -->
                                <!-- 1进行总 2，已开始 3，以结束 -->
                                <span class="shangke" v-if="item.status_extra == 3 && item.teacher_is_comment==2"
                                    @click="fnXuePingjia(item)">写评价</span>
                                <span class="shangke" @click="Teachershow(item.id)"
                                    v-if="item.teacher_is_comment == 1 && item.status_extra == 3">查看评价</span>
                                <span class="chakan" v-if="item.status_extra != 3" @click="readMe(item)">查看教材</span>
                                <span class="chakan" v-if="item.status_extra == 3"
                                    @click="fnPlayBack(item.id)">查看回放</span>
                            </div>
                        </div>
                    </div>
                </template>
                <template v-for="(items,index) in appointment">
                    <div class="list">
                        <div class="time">
                            {{items.start_time}}
                        </div>
                        <div class="title">
                            {{items.live_name}}
                        </div>
                        <div class="order">
                            考核人 {{items.teacher_name}}
                            <div class="btn">
                                <!-- <span class="shangke" :data-starttime="items.start_time" :data-appintid="items.id"  :data-index="index" @click="fnStartClass($event)" >开始上课</span> -->
                                <span class="shangke" :data-starttime="items.start_time" :data-appintid="items.id"
                                    :data-index="index" @click="fnStartClass(items)"
                                    v-if="items.status_extra != 3">开始上课</span>
                                <!-- <span class="shangke" v-if="item.status == '已结束'" >已结束</span> -->
                                <!-- 1进行总 2，已开始 3，以结束 -->
                                <span class="shangke" v-if="items.status_extra == 3 && item.teacher_is_comment==2"
                                    @click="fnXuePingjia(items)">写评价</span>
                                <span class="shangke" @click="Teachershow(items.id)"
                                    v-if="items.teacher_is_comment == 1 && items.status_extra == 3">查看评价</span>
                                <span class="chakan" v-if="items.status_extra != 3" @click="readMe(items)">查看教材</span>
                                <span class="chakan" v-if="items.status_extra == 3"
                                    @click="fnPlayBack(items.id)">查看回放</span>
                            </div>
                        </div>
                    </div>
                </template>
                <template v-for="(items,index) in appointmented">
                    <div class="list">
                        <div class="time">
                            {{items.start_time}}
                        </div>
                        <div class="title">
                            {{items.live_name}}
                        </div>
                        <div class="order">
                            讲师 {{items.teacher_name}}
                            <div class="btn">
                                <span class="shangke" :data-starttime="items.start_time" :data-appintid="items.id"
                                    :data-index="index" @click="fnStartClass(items)"
                                    v-if="items.status_extra != 3">开始上课</span>
                                <!-- <span class="shangke" v-if="item.status == '已结束'" >已结束</span> -->
                                <!-- 1进行总 2，已开始 3，以结束 -->
                                <span class="shangke" v-if="items.status_extra == 3 && items.teacher_is_comment==2"
                                    @click="fnXuePingjia(items)">写评价</span>
                                <span class="shangke" @click="Teachershow(items.id)"
                                    v-if="items.teacher_is_comment == 1 && items.status_extra == 3">查看评价</span>
                                <span class="chakan" v-if="items.status_extra != 3" @click="readMe(items)">查看教材</span>
                                <span class="chakan" v-if="items.status_extra == 3"
                                    @click="fnPlayBack(items.id)">查看回放</span>
                            </div>
                        </div>
                    </div>
                </template>
            </div>
            <!-- 考核 -->
            <div class="package" v-if="!tabFlag">
                <template v-for="(item,index) in kaoheList">
                    <div class="list">
                        <div class="time">
                            {{item.appoint_time}}
                        </div>
                        <div class="title">
                            授课资格考核
                        </div>
                        <div class="order">
                            被考核人 {{item.teacher_name}}
                            <div class="btn">
                                <span class="shangke" :data-starttime="item.appoint_time" :data-appintid="item.id"
                                    :data-index="index" @click="fnStartAssess($event)" v-if="item.is_end == 2">开始</span>
                                <span class="shangke" v-if="item.is_end == 1">已结束</span>
                                <span class="shangke" @click="fnPingjia(item)"
                                    v-if="item.is_comment == 2 && item.is_end == 1">填写评价</span>
                                <span class="shangke" @click="show(item.id)"
                                    v-if="item.is_comment == 1 && item.is_end == 1">查看评价</span>
                                <!--<span class="shangke" @click="fnPingjia(item.id)"  >填写评价</span>
                                <span class="shangke" @click="show(item.id)" >查看评价</span> -->
                            </div>
                        </div>
                    </div>
                </template>
            </div>
        </div>
        <div class="defule" v-if="kechengFlag && !alertFlag">
            <img src="./image//wuyuedu2.png" alt="">
            <p>{{kecheng}}</p>
        </div>
        <div class="tip_alert" v-if='alertFlag'>
            <div>{{text}}</div>
        </div>
        <div class="tianxie" v-if="laoshiP">
            <div class="tbox">
                <img src="./image/close.png" alt="" @click="fnClose()" class="close">
                <div class="box">
                    <h3>填写评价</h3>
                    <div class="p1">
                        <div>考核结果</div>
                        <div>
                            <span :class="{t1:status == 1,t2:status!=1,point:chakan}" @click="tongguo(1)">通过</span>
                            <span :class="{t1:status == 2,t2:status!=2,point:chakan}" @click="tongguo(2)">不通过</span>
                        </div>
                    </div>
                    <div class="p1" v-if="starFlag">
                        <div class="kh">能力评级</div>
                        <!-- 下拉选择评级 -->
                        <select @change="fnTeacherChange($event)">
                            <option :value="item.id" v-for="item in teacherLiveList ">{{item.name}}</option>
                        </select>
                        <!-- <div class="tab" :class="{point:chakan}">
                            <img v-for="(star,index) in stars" v-bind:src="star.src" v-on:click="rating(index)" alt="星星图片" />
                        </div> -->
                    </div>
                    <div class="p1 p2">
                        <div>填写评语</div>
                        <textarea v-model="contents"></textarea>
                    </div>
                    <div class="btn" @click="fnSubmit" v-if="subFlag == 1">提交</div>
                </div>
            </div>
            <div class="msk"></div>
        </div>
        <div class="tianxie" v-if="xueshengP">
            <div class="tbox">
                <img src="./image/close.png" alt="" @click="fnXueClose()" class="close">
                <div class="box">
                    <h3>填写评价</h3>
                    <div class="p1" v-if="xueshengstarFlag">
                        <div class="kh">评级</div>
                        <select @change="fnChange($event)">
                            <option :value="item.id" v-for="item in liveList">{{item.name}}</option>
                        </select>
                    </div>
                    <div class="p1 p2">
                        <div>填写评语</div>
                        <textarea v-model="xueshengContent"></textarea>
                    </div>
                    <div class="btn" @click="fnXueSubmit" v-if="subXueFlag == 1">提交</div>
                </div>
            </div>
            <div class="msk"></div>
        </div>
        <div class="play" v-if="videoFlag">
            <div class="playbox" v-if="video">
                <video id="my_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640"
                    height="264" poster="" data-setup="{}">
                    <source :src="video" type='video/mp4'>
                    <!-- <source src="my_video.webm" type='video/webm'> -->
                </video>
            </div>
            <div v-if="!video" class="playno" @click="mskClose">
                <img src="./image/wuyuedu2.png" alt="">
                <p>暂无回放</p>
            </div>
            <div class="msk" @click="mskClose"></div>
        </div>
        <div class="bgc" @mouseout="fnMouseout($event)" @mouseover="fnFouseover($event)"></div>
    </div>
    <div id="pdf">
        <div class="guanbi" onclick="guanbi()">关闭</div>
        <div class="msk"></div>
        <div id="pdfbox" onclick="guanbi()"></div>
    </div>
</body>
<script src="./libs/thirdpart/vue.js"></script>
<script src="js/axios.js"></script>
<script src="js/moment.js"></script>
<script src="./js/pdfobject.js"></script>
<script src="./js/playvideo.js"></script>
<script src="./js/base.js"></script>
<script>
    var vm;
    var token = localStorage.token;
    var AUTH_TOKEN = 'Bearer ' + token;
    axios.defaults.baseURL = baseURL;
    axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
    axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
    window.onload = function () {
        console.log(token)
        if (!token) {
            window.location.href = './html/login.html'
        }
    }
    var starOffImg = "./image/icon_star.png";
    var starOnImg = "./image/icon_star_act.png";

    function guanbi() {
        var pdf = document.querySelector('#pdf');
        pdf.style.display = 'none'
    }
    vm = new Vue({
        el: '#app',
        data: {
            tabList: [],
            selectIndex: 0,
            token: token,
            status: 2,
            page: 1,
            pagesize: 10,
            classList: [],
            alertFlag: false,
            text: '',
            teacherInfo: {},
            kaoheList: [],
            tabFlag: true,
            appointment: [],
            appointmented: [],
            starIndex: 0,
            subXueFlag: 1,
            loginoutboxFlag: false,
            stars: [{
                src: starOffImg,
                active: false
            }, {
                src: starOffImg,
                active: false
            }, {
                src: starOffImg,
                active: false
            }, {
                src: starOffImg,
                active: false
            }, {
                src: starOffImg,
                active: false
            }],
            starNum: 0,
            contents: '',
            level_id: '',
            appoint_id: '',
            starFlag: true,
            tianxie: false,
            subFlag: 1,
            kechengFlag: false,
            kecheng: '',
            chakan: false,
            xiepignjiaFlag: 0,
            xueshengP: false,
            laoshiP: false,
            changeL: null,
            video: '',
            videoFlag: false,
            xueshengContent: [],
            xueshengstarFlag: true,
            is_train_teacher: null,
            inputFile: '',
            inputVal: '11',
            teacherLe: 1,
            teacherLiveList: []
        },
        created() {
            this.fnGetTeacher()
            this.fnAppointmentx(true);
            this.getList();
            // this.fnExamination(true)
            this.fnLive();
            // console.log(this.tabFlag)
            // this.getInput()
        },
        mounted: function () {

        },
        methods: {
            getFile() {
                let textbook = 'https://moyadou-1301152902.cos.ap-beijing.myqcloud.com/2020-07-07_1594114100_5f04403486d31.pdf';
                let nickname = this.teacherInfo.nickname;
                let mobile = this.teacherInfo.mobile;
                let area = this.teacherInfo.area;
                let url = './html/couse.html?textbook=' + textbook + '&nickname=' + nickname + '&mobile=' + mobile + '&area=' + area;
                window.open(url)
            },
            fnMouseout: function () {
                var msk = document.querySelector('.msk')
                setTimeout(() => {
                    msk.style.display = "none"
                }, 2400);
            },
            fnFouseover: function () {
                var msk = document.querySelector('.msk');
                msk.style.display = "block"
            },
            readMe: function (item) {
                var textbook = item.textbook;
                // let textbook = 'https://moyadou-1301152902.cos.ap-beijing.myqcloud.com/2020-07-07_1594114100_5f04403486d31.pdf';
                let nickname = this.teacherInfo.nickname;
                let mobile = this.teacherInfo.mobile;
                let area = this.teacherInfo.area;
                let url = './html/couse.html?textbook=' + textbook + '&nickname=' + nickname + '&mobile=' + mobile + '&area=' + area + '&class_id=' + item.class_id;
                window.open(url)
                console.log(item.textbook);
            },
            fnPlayBack(id) {
                axios.get('/api/class/playback/show?appoint_id=' + id)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            this.video = response.data.data.url;
                            if (!response.data.data.url) {
                                this.ToastOpen('暂无回放')
                            } else {
                                this.videoFlag = true;
                            }

                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            mskClose() {
                this.videoFlag = false;
            },
            loginBox() {
                this.loginoutboxFlag = !this.loginoutboxFlag;
                setTimeout(() => {
                    this.loginoutboxFlag = !this.loginoutboxFlag
                }, 3000);
            },
            loginBox1() {
                this.loginoutboxFlag = false
            },
            loginOut() {
                window.location.href = './html/login.html'
            },
            fnTextBook: function () {

            },
            fnClose: function () {
                this.tianxie = false;
                this.chakan = false;
                this.xueshengP = false;
                this.laoshiP = false
            },
            fnXueClose() {
                this.tianxie = false;
                this.chakan = false;
                this.xueshengP = false;
                this.laoshiP = false
                this.subXueFlag = 1;
                this.xueshengContent = '';
                this.xueshengstarFlag = true;
            },
            //api/teacher/train/level/show?appoint_id=1
            Teachershow(id) {
                this.tianxie = true;
                this.subFlag = 2;
                this.chakan = true;
                this.xueshengP = true;
                this.subXueFlag = 2;
                this.xueshengstarFlag = false;
                axios.get('/api/teacher/comment/show?appoint_id=' + id)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            this.xueshengContent = response.data.data.contents;
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            show: function (id) {
                this.tianxie = true;
                this.subFlag = 2;
                this.chakan = true;
                this.laoshiP = true;
                // axios.get('/api/teacher/train/level/show?appoint_id=1')
                axios.get('/api/teacher/train/level/show?appoint_id=' + id)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            this.contents = response.data.data.contents;
                            this.starNum = response.data.data.level_id;
                            this.status = response.data.data.status;
                            for (var i = 0; i < response.data.data.level_id; i++) {
                                this.stars[i].active = true;
                                this.stars.splice(i, 1, {
                                    src: starOnImg,
                                    active: true
                                })
                            }
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            fnChange(e) {
                var ev = e.target.value
                this.changeL = ev;
            },
            fnTeacherChange(e) {
                this.teacherLe = e.target.value;
                console.log(this.teacherLe)
            },
            fnPingjia: function (item, index) {
                this.appoint_id = item.id;
                this.stuid = item.student_user_id;
                this.classid = item.class_id;
                this.tianxie = true;
                this.subFlag = 1;
                this.chakan = false;
                this.xiepignjiaFlag = index;
                this.laoshiP = true;
            },
            fnXuePingjia: function (item) {
                this.contents = '';
                this.xueshengP = true;
                this.stuid = item.student_user_id;
                this.appoint_id = item.id;
                this.stuid = item.student_user_id;
                this.classid = item.class_id;
                if (item.level_id == 0) {
                    this.xueshengT = true
                }
                if (item.is_audition == 1) {
                    this.xueshengstarFlag = true
                } else {
                    this.xueshengstarFlag = false
                }
            },
            tongguo: function (index) {
                if (index == 1) {
                    this.status = 1;
                    // this.starFlag = true;
                } else {
                    this.status = 2;
                    // this.starFlag = false
                }
            },
            fnSubmit: function () {
                var level_id;
                if (this.status == 2) {
                    level_id = 0
                } else {
                    // level_id = this.starNum
                    level_id = this.teacherLe
                }
                if (!this.contents) {
                    this.ToastOpen('请填写评语');
                    return;
                }
                var parme = {
                    appoint_id: this.appoint_id,
                    contents: this.contents,
                    level_id: level_id,
                    status: this.status
                };
                axios.post('/api/teacher/train/level/create', parme)
                    .then((response) => {
                        if (response.data.code == 10200) {
                            this.ToastOpen(response.data.msg);
                            this.fnExamination(true);
                            this.laoshiP = false;
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            fnXueSubmit() {
                var levelid;
                if (this.liveList.length == 0) {
                    this.ToastOpen('等级列表为空无法提交,联系管理员添加');
                    return;
                }
                if (this.xueshengContent == '') {
                    this.ToastOpen('请填写评语');
                    return;
                }
                var parme = {
                    student_user_id: this.stuid,
                    class_id: this.classid,
                    contents: this.xueshengContent,
                    level_id: this.changeL || this.liveList[0].id,
                    appoint_id: this.appoint_id,
                }
                // var parme = {
                //     student_user_id: '20',
                //     class_id: '39',
                //     contents: '犯得上看见发的时刻',
                //     level_id: this.liveList[0].id,
                //     appoint_id: '883'
                // }
                console.log(parme)
                axios.post('/api/teacher/comment/create', parme)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            this.ToastOpen(response.data.msg);
                            this.fnAppointmentx(true);
                            this.xueshengP = false;
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            getList() {
                //学生等级
                axios.get('/api/class/level/list')
                    .then((response) => {
                        if (response.data.code == 10200) {
                            this.liveList = response.data.data;
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
                //老师等级
                axios.get('/api/user/teacher/level/list')
                    .then((response) => {
                        if (response.data.code == 10200) {
                            this.teacherLiveList = response.data.data;
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            rating: function (index) {
                var total = this.stars.length; //星星总数
                var idx = index + 1; //这代表选的第idx颗星-也代表应该显示的星星数量

                //进入if说明页面为初始状态
                if (this.starNum == 0) {
                    this.starNum = idx;
                    for (var i = 0; i < idx; i++) {
                        this.stars[i].src = starOnImg;
                        this.stars[i].active = true;
                    }
                } else {
                    //如果再次点击当前选中的星级-仅取消掉当前星级，保留之前的。
                    if (idx == this.starNum) {
                        for (var i = index; i < total; i++) {
                            this.stars[i].src = starOffImg;
                            this.stars[i].active = false;
                        }
                    }
                    //如果小于当前最高星级，则直接保留当前星级
                    if (idx < this.starNum) {
                        for (var i = idx; i < this.starNum; i++) {
                            this.stars[i].src = starOffImg;
                            this.stars[i].active = false;
                        }
                    }
                    //如果大于当前星级，则直接选到该星级
                    if (idx > this.starNum) {
                        for (var i = 0; i < idx; i++) {
                            this.stars[i].src = starOnImg;
                            this.stars[i].active = true;
                        }
                    }

                    var count = 0; //计数器-统计当前有几颗星
                    for (var i = 0; i < total; i++) {
                        if (this.stars[i].active) {
                            count++;
                        }
                    }
                    this.starNum = count;
                }
            },

            fnSelcet: function (index) {
                // console.log(index)
                // console.log(this.starIndex)
                this.starIndex = index + this.starIndex;
                // console.log(this.starIndex)
            },
            fnSelcetAct: function (index) {
                this.starIndex = this.starIndex - index;
            },
            fnTabbar(index, status) {
                this.page = 1;
                this.selectIndex = index;
                this.status = status;
                this.appointment = [];
                this.appointmented = [];
                this.classList = [];
                this.kaoheList = [];
                this.kechengFlag = false;
                if (index == 0 || index == 2) {
                    this.tabFlag = true;
                    this.fnAppointmentx(true);
                } else {
                    this.tabFlag = false
                    this.fnExamination(true)
                }
            },
            //直播预约api/teacher/train/appointment/live/list
            fnLive() {
                axios.get('/api/teacher/train/appointment/live/list')
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            if (response.data.data.length != 0) {
                                if (response.data.data.appointment.length != 0) {
                                    this.appointment = response.data.data.appointment;
                                }
                                if (response.data.data.appointmented.length != 0) {
                                    this.appointmented = response.data.data.appointmented;
                                }
                                if (this.appointment.length == 0 && this.appointmented.length == 0 && this.classList.length == 0) {
                                    this.kechengFlag = true;
                                } else {
                                    this.kechengFlag = false;
                                }
                            }
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            //课程列表
            fnAppointmentx(reload) {
                var url;
                // console.log()
                if (this.selectIndex == 2) {
                    this.classList = []
                    url = '/api/teacher/appointment/class/list?status=' + this.status + '&pagesize=30'
                } else {
                    if (reload) {
                        this.classList = [];
                        this.page = 1;
                    } else {
                        this.page++
                    }
                    url = '/api/teacher/appointment/class/list?status=' + this.status + '&page=' + this.page + '&pagesize=30'
                }
                // console.log(url)
                axios.get(url)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            this.fnLive();
                            if (response.data.data.length != 0) {
                                this.classList = this.classList.concat(response.data.data.data);
                            } else {
                                this.kecheng = '暂无课程'
                                if (this.page > 1) {
                                    this.ToastOpen('没有更多了')
                                }
                            }

                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            //考核管理
            fnExamination(reload) {
                if (reload) {
                    this.kaoheList = [];
                    this.page = 1;
                } else {
                    this.page++
                }
                // console.log(this.status + '&page=' + this.page + '&pagesize=' + this.pagesize)
                axios.get('/api/teacher/train/examination/list?type=' + this.status + '&page=' + this.page + '&pagesize=' + this.pagesize)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            if (response.data.data.data.length != 0) {
                                this.kaoheList = this.kaoheList.concat(response.data.data.data);
                            } else {
                                // console.log(this.kechengFlag)
                                // this.kechengFlag = true;
                                this.kecheng = '暂无考核';
                                if (this.page > 1) {
                                    this.ToastOpen('没有更多了')
                                }
                            }
                            if (this.kaoheList.length == 0) {
                                this.kechengFlag = true;
                            } else {
                                this.kechengFlag = false;
                            }
                        } else {
                            this.ToastOpen(response.data.msg)
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            ToastOpen(text) {
                this.alertFlag = !this.alertFlag;
                this.text = text;
                setTimeout(() => {
                    this.alertFlag = !this.alertFlag;
                }, 2000)
            },
            //老师考核
            fnStartAssess(ev) {
                if (this.selectIndex == 1) {
                    var teacherId = 'teacherId' + ev.train_teacher_id;
                } else {
                    var teacherId = 'teacherId' + ev.train_teacher_user_id;
                }
                var appid = ev.id;
                var starttime = ev.appoint_time;
                // var index = ev.target.dataset.index;
                // var  starttime = '2020-5-21 33:20';
                var chidao = false;
                var obj = {
                    time: starttime,
                    hadTime: 5,
                    math: 'subtract'
                }
                var obj2 = {
                    time: starttime,
                    hadTime: 15,
                    math: 'add'
                }
                var obj3 = {
                    time: starttime,
                    hadTime: 0,
                    math: 'add'
                }
                var obj4 = {
                    time: starttime,
                    hadTime: 14,
                    math: 'add'
                };
                var a = this.timesTamp(obj);
                var b = this.timesTamp(obj2);
                var c = this.timesTamp(obj3);
                var d = this.timesTamp(obj4);
                if (a < 0) {
                    this.ToastOpen('未到考核时间');
                    return
                };
                if (c > 0 && d < 0) {
                    chidao = true;
                }
                var parme = {
                    appoint_id: appid
                }
                axios.post('/api/teacher/train/examination/enter', parme)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            axios.post('/api/user/sig/register', {
                                username: teacherId
                            }).then((res) => {
                                // console.log(res);
                                var winHref = {
                                    roomId: appid,
                                    appintId: appid,
                                    userId: teacherId,
                                    userToken: res.data.data.sig,
                                    starttime: starttime
                                };
                                var href = "./html/live.html?id=" + winHref.roomId + "&appintId=" + appid + "&userId=" + winHref.userId + "&userToken=" + winHref.userToken + '&chidao=' + chidao + '&starttime=' + starttime;
                                // console.log(href);
                                window.location.href = href;
                            })

                            // var index = 0;
                            // var winHref = {
                            //     roomId: 1,
                            //     appintId: appid,
                            //     userId: encodeURI(encodeURI('pad123')),
                            //     userToken: 'eJwtzF0LgjAYhuH-stPCXq01J3RkIYInUoRBJ4tNeTHHNNv6oP*eqIfP9cD9Jafs6FnVkYgEHpDluFEq3WOJI1dPI7QTuprPh6yFMShJ5G8A1oyFWzY96mWwU4NTSgMAmLTHZjQOzOc8pHMFq6HtZ4WzeU7vRqrksNft4iOt45heWla*b9Ccrysmkrgu4nRHfn*IZzPh'
                            // };
                            // // this.intoStudio(winHref)
                            // if (index == 0) {
                            //     var href = "./html/live.html?id=" + winHref.roomId + "&appintId=" + appid + "&userId=" + winHref.userId + "&userToken=" + winHref.userToken + '&chidao=' + chidao;
                            //     console.log(href);
                            //     window.location.href = href;
                            // }
                            // if (index == 1) {
                            //     var href = "./html/live.html?id=1&appintId=" + appid + "&userId=" + encodeURI(encodeURI('gupanwang')) + "&userToken=eJwtzF0LgjAYhuH-stPCXq01J3RkIYInUoRBJ4tNeTHHNNv6oP*eqIfP9cD9Jafs6FnVkYgEHpDluFEq3WOJI1dPI7QTuprPh6yFMShJ5G8A1oyFWzY96mWwU4NTSgMAmLTHZjQOzOc8pHMFq6HtZ4WzeU7vRqrksNft4iOt45heWla*b9Ccrysmkrgu4nRHfn*IZzPh";
                            //     window.location.href = href;
                            // }
                            // if (index == 2) {
                            //     var href = "./html/live.html?id=1&appintId=" + appid + "&userId=" + encodeURI(encodeURI('gupanwang')) + "&userToken=eJwtzF0LgjAYhuH-stPCXq01J3RkIYInUoRBJ4tNeTHHNNv6oP*eqIfP9cD9Jafs6FnVkYgEHpDluFEq3WOJI1dPI7QTuprPh6yFMShJ5G8A1oyFWzY96mWwU4NTSgMAmLTHZjQOzOc8pHMFq6HtZ4WzeU7vRqrksNft4iOt45heWla*b9Ccrysmkrgu4nRHfn*IZzPh";
                            //     console.log(href)
                            //     window.location.href = href;
                            // }
                        } else {
                            this.ToastOpen(response.data.msg);
                            return false;
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            //老师上课
            fnStartClass(ev) {
                // console.log(ev);
                var appid = ev.id;
                var starttime = ev.appoint_time;
                var teacher_nickname = ev.teacher_nickname;
                var teacherId = 'teacherId' + ev.teacher_user_id;
                var studentId = 'studentId' + ev.student_user_id;
                var class_id = ev.class_id;
                // console.log(studentId)
                var textbook = ev.textbook;
                // var  starttime = '2020-5-21 33:20';
                var chidao = false;
                var obj = {
                    time: starttime,
                    hadTime: 5,
                    math: 'subtract'
                }
                var obj2 = {
                    time: starttime,
                    hadTime: 50,
                    math: 'add'
                }
                var obj3 = {
                    time: starttime,
                    hadTime: 0,
                    math: 'add'
                }
                var obj4 = {
                    time: starttime,
                    hadTime: 14,
                    math: 'add'
                }
                var a = this.timesTamp(obj);
                var b = this.timesTamp(obj2);
                var c = this.timesTamp(obj3);
                var d = this.timesTamp(obj4);
                if (b > 0) {
                    this.ToastOpen('课程结束了，不能进入直播间');
                    return;
                }
                // if (a < 0) {
                //     this.ToastOpen('未到上课时间');
                //     return
                // }
                if (c > 0 && d < 0) {
                    chidao = true;
                }
                var parme = {
                    appoint_id: appid
                }
                axios.post('/api/teacher/appointment/class/enter', parme)
                    .then((response) => {
                        // console.log(response)
                        if (response.data.code == 10200) {
                            axios.post('/api/user/sig/register', {
                                username: teacherId
                            }).then((res) => {
                                var winHref = {
                                    roomId: appid,
                                    appintId: appid,
                                    userId: teacherId,
                                    studentName: studentId,
                                    userToken: res.data.data.sig,
                                    starttime: starttime,
                                    class_id: class_id
                                };
                                console.log(class_id);
                                var href = "./html/live.html?id=" + winHref.roomId + "&appintId=" + appid + "&studentName=" + winHref.studentName + "&userId=" + winHref.userId + "&userToken=" + winHref.userToken + '&chidao=' + chidao + '&textbook=' + textbook + '&starttime=' + starttime + '&class_id=' + class_id;
                                window.location.href = href;
                            })

                            // var index = 0;
                            // var winHref = {
                            //     roomId: 1,
                            //     appintId: appid,
                            //     userId: encodeURI(encodeURI('pc')),
                            //     userToken: 'eJwtzF0LgjAYhuH-suOwd3NzTugkFBI6KiGCTtyH8SLJ0LGC6L8n6uFzPXB-SXO*JtGNpCAsAbJbNlo3BOxwYW82nWzfeo*WFJQDpFLmmVwf9-E4utmFEAwAVg34WkyBUlJyulXwOUdpNkVTSxqqqHlnNfPtYFh5oe-bqdd3n8a6zINuHvtjdSC-P5wDMGM_'
                            // };
                            // // this.intoStudio(winHref)
                            // if (index == 0) {
                            //     var href = "./html/live.html?id=" + winHref.roomId + "&appintId=" + appid + "&userId=" + winHref.userId + "&userToken=" + winHref.userToken + '&chidao=' + chidao;
                            //     console.log(href);
                            //     window.location.href = href;
                            // }
                            // if (index == 1) {
                            //     var href = "./html/live.html?id=1&appintId=" + appid + "&userId=" + encodeURI(encodeURI('gupanwang')) + "&userToken=eJwtzFELgjAUhuH-sttCTq61JnQVRUERmZZdjnaUgzjG0gqj-56ol9-zwftlyeESvNCziIUBsGm-yaCtKaeei8Zp*9a2GM*nKbVzZFg0mwNwKZcLOTz4ceSxcyFECACD1lT1pkByAMXHChVd*7RBmcS7ta-qzO7bOIuvcMeSRH7EtD1vJ6rhlN0wzR8r9vsDSBczfA__";
                            //     console.log(href)
                            //     return
                            //     window.location.href = href;
                            // }
                            // if (index == 2) {
                            //     var href = "./html/live.html?id=1&appintId=" + appid + "&userId=" + encodeURI(encodeURI('gupanwang')) + "&userToken=eJwtzFELgjAUhuH-sttCTq61JnQVRUERmZZdjnaUgzjG0gqj-56ol9-zwftlyeESvNCziIUBsGm-yaCtKaeei8Zp*9a2GM*nKbVzZFg0mwNwKZcLOTz4ceSxcyFECACD1lT1pkByAMXHChVd*7RBmcS7ta-qzO7bOIuvcMeSRH7EtD1vJ6rhlN0wzR8r9vsDSBczfA__";
                            //     console.log(href)
                            //     window.location.href = href;
                            // }
                        } else {
                            this.ToastOpen(response.data.msg);
                            return false;
                        }
                    })
                    .catch(function (error) {
                        console.log(error);
                    });
            },
            //进入直播间Into the studio
            intoStudio(parme) {
                var href = "./html/live.html?id=" + parme.roomId + "&appintId=" + parme.appid + "&userId=" + parme.userId + "&userToken=" + parme.userToken + '&chidao=' + parme.chidao;
                window.location.href = href;
            },
            timesTamp(obj) {
                var curr = new Date().getTime()
                var time = obj.time;
                var hadTime = obj.hadTime;
                var times;
                // console.log(new Date())
                // console.log(time)
                if (obj.math == 'add') {
                    time = moment(time).add(hadTime, 'm').format('YYYY-MM-DD HH:mm:ss')
                } else {
                    time = moment(time).subtract(hadTime, 'm').format('YYYY-MM-DD HH:mm:ss')
                }
                times = curr - new Date(time).getTime();
                return times;
            },
            fnGetTeacher() {
                var _this = this;
                axios.get('/api/user/teacher/show').then((res) => {
                    if (res.data.code == 10466) {
                        window.location.href = './html/login.html'
                    } else if (res.data.code == 10200) {
                        this.teacherInfo = res.data.data;
                        this.is_train_teacher = res.data.data.is_train_teacher;
                        if (res.data.data.is_train_teacher == 1) {
                            this.tabList = [{
                                name: '上课管理',
                                status: 2
                            }, {
                                name: '考核管理',
                                status: 1
                            }, {
                                name: '上课历史',
                                status: 1
                            }, {
                                name: '老师考核',
                                status: 2
                            }]
                        } else {
                            this.tabList = [{
                                name: '上课管理',
                                status: 2
                            }, {
                                name: '考核管理',
                                status: 1
                            }, {
                                name: '上课历史',
                                status: 1
                            }]
                        }
                    }
                    // console.log(res.data.data)
                })
            }
        }
    });
    //获取滚动条当前的位置 
    function getScrollTop() {
        var scrollTop = 0;
        if (document.documentElement && document.documentElement.scrollTop) {
            scrollTop = document.documentElement.scrollTop;
        } else if (document.body) {
            scrollTop = document.body.scrollTop;
        }
        return scrollTop;
    }

    //获取当前可视范围的高度 
    function getClientHeight() {
        var clientHeight = 0;
        if (document.body.clientHeight && document.documentElement.clientHeight) {
            clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
        } else {
            clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
        }
        return clientHeight;
    }

    //获取文档完整的高度 
    function getScrollHeight() {
        return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
    }

    //滚动事件触发
    window.onscroll = function () {
        if (getScrollTop() + getClientHeight() == getScrollHeight()) {
            // console.log(vm.tabFlag)
            if (vm.tabFlag) {
                if (vm.selectIndex == 0) {
                    vm.fnAppointmentx(false)
                }
            } else {
                // console.log(222)
                vm.fnExamination(false)
            }
        }
    }
</script>

</html>